package com.glorysoft.knowlespda.model
import com.glorysoft.knowlespda.base.BaseRepository
import com.glorysoft.knowlespda.base.Constant
import com.glorysoft.knowlespda.entity.LoginEntity
import com.glorysoft.knowlespda.entity.LotEntity
import com.google.gson.JsonObject
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse


/**
 * FileName: LoginRepository
 * Author: XJH
 * Date: 2021/5/24 17:11
 * Description:
 * History:
 */
class TrackRepository : BaseRepository() {

    suspend fun getSiteInformation(map: JsonObject): LotEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"GetSiteInfor"))
            .toResponse<LotEntity>()
            .await()


    }

    suspend fun getWaferListPartial(map: JsonObject): LotEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"GetWaferListPartial"))
            .toResponse<LotEntity>()
            .await()


    }


    suspend fun siteOperation(map: JsonObject,type : String): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,if (type == "IN") "TrackInOperation" else "TrackOutOperation"))
            .toResponse<JsonObject>()
            .await()


    }

    suspend fun siteFerOperation(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"TransferOperation"))
            .toResponse<JsonObject>()
            .await()


    }

    suspend fun getJobInfo(map: JsonObject): LotEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"GetJobInfo"))
            .toResponse<LotEntity>()
            .await()


    }

    suspend fun getEngineeringSubmit(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"PDAEngineeringModeSubmit"))
            .toResponse<JsonObject>()
            .await()


    }
}